#include<iostream>
#include<unistd.h>

using namespace std;

int main()
{
    int fd[2];
    if(-1==pipe(fd))
    {
        perror("pipe");
        exit(-1);
    }
    pid_t pid=fork();
    if(0==pid)
    {
        char buf[30];
        read(fd[0],buf,sizeof(buf));
        printf("%s\n",buf);

        return 0;
    }
    if(pid>0)
    {
        char buf[]="i am father";
        write(fd[1],buf,sizeof(buf));
        
        sleep(1);
    }

    return 0;
}